package com.gagakuai.app.flink.map;

import com.gagakuai.domain.facts.Fact;
import com.gagakuai.infrastructure.utils.MysqlUtil;
import org.apache.flink.api.common.functions.RichFlatMapFunction;
import org.apache.flink.api.java.utils.ParameterTool;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.util.Collector;

import java.sql.Connection;
import java.sql.PreparedStatement;

/**
 * @description:
 * @author: houhong
 * @create: 2024-09-07 20:43
 **/
public class IndexCalculateFlatMap extends RichFlatMapFunction<Fact<?>,Fact<?>> {

    private ParameterTool parameterTool = null;
    private PreparedStatement ps = null;
    private Connection conn = null;


    @Override
    public void flatMap(Fact<?> fact, Collector<Fact<?>> collector) throws Exception {

    }

    @Override
    public void open(Configuration parameters) throws Exception {

        super.open(parameters);

        //获取全局 ParameterTool
        parameterTool = (ParameterTool) getRuntimeContext().getExecutionConfig().getGlobalJobParameters();

        //获取 Connection 对象
        conn = MysqlUtil.init(parameterTool);

    }
}
